﻿using DataAccess.DTO;
using DataAccess.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XYD.DataAccess;
using XYD.Framework.Data;
using XYD.Framework.Data.Dapper;

namespace DataAccess.DAL
{
    public class CategoryDAL : BaseDAL
    {
        public Category Get(int id)
        {
            return CONN_TopicSharing.Get<Category>(id);
        }

        public bool Insert(Category Category)
        {
            
            return CONN_TopicSharing.Insert<Category>(Category);
        }

        public bool Update(Category Category)
        {
            return CONN_TopicSharing.Update<Category>(Category);
        }
 
         public List<Category> GetCategorys()
         {
             return CONN_TopicSharing.SQLQuery<Category>(" select * from Category ", null).ToList();
         }

        public List<Category> GetCategorys(string strWhere, string orderbys, int pagesize, int pageindex, out int count)
        {
            List<Category> Categorys = new List<Category>();
            if (string.IsNullOrEmpty(strWhere))
            {
                strWhere = " 1=0 ";
            }

            if (string.IsNullOrEmpty(orderbys))
                orderbys = "id";

            Categorys = CONN_TopicSharing.SQLPager<Category>("*", " Category", strWhere, "", "", orderbys, pagesize, pageindex, out count, null).ToList();

            return Categorys;
        }
         
    }
}
